import {requestGet} from "util/request";
import {Part} from "type/Part";
import {Result} from "type/Result";
import {OutboundDeliveryOrder} from "type/OutboundDeliveryOrder";
import {ClientInfo} from "type/ClientInfo";
import {EngineInfo} from "type/EngineInfo";
import {PartProvider} from "type/PartProvider";
import {PartGroup} from "type/PartGroup";

/**
 * 根据零件ID查询零件信息
 * @param id 零件编号
 * @return Promise<Result<Part>> 零件信息
 */
export const requestPartById = async (id: string | number | undefined): Promise<Result<Part>> => {
    if (id){
        return await requestGet<Part>("/calista/part/one/" + id);
    }
    return new Promise((resolve) => {
        resolve({success: false,code: 0,message: "零件编号为空", data: {} as Part});
    }) ;
} ;

/**
 * 查询客户信息列表
 */
export const requestClientList = async (): Promise<Result<ClientInfo[]>> => {
   return await requestGet<ClientInfo[]>("/calista/client-info/list") ;
} ;

/**
 * 查询发动机信息列表
 */
export const requestEngineInfo = async (): Promise<Result<EngineInfo[]>> => {
    return await requestGet<EngineInfo[]>("/calista/engine-info/list") ;
} ;

/**
 * 查询出库单列表
 */
export const requestOdoList = async (): Promise<Result<OutboundDeliveryOrder[]>> => {
    return await requestGet<OutboundDeliveryOrder[]>("/calista/odo/list") ;
} ;
/**
 * 查询零件供应商列表
 */
export const requestPartProviderList = async (): Promise<Result<PartProvider[]>> => {
    return await requestGet<PartProvider[]>("/calista/part-provider/list") ;
} ;
/**
 * 查询零件分组列表
 */
export const requestPartGroupList = async (): Promise<Result<PartGroup[]>> => {
    return await requestGet<PartGroup[]>("/calista/part-group/list") ;
} ;
